<?php

/*
 * 默认的
*/
$router->get('/', function () use ($router) {
//    echo phpinfo();
//    return $router->app->version();
    echo $_SERVER['REQUEST_URI'];
    if (strpos($_SERVER['REQUEST_URI'], '/h5/') == true) {
        return redirect('/h5/index.html?code=' . $_GET['code']);
    }
    else if (strpos($_SERVER['REQUEST_URI'], '/h5fuwu/index.html') == true) {
        return redirect('/h5fuwu/jiazheng/index.html');
    }
    else if (strpos($_SERVER['REQUEST_URI'], '/admin') == true) {
        return redirect('/admin/index.html');
    }
    else {
        return redirect('/front/index.html');
    }
});


//后台接口
$router->group(['prefix'=>'/api/admin', 'namespace'=>'Admin'], function () use ($router) {
    $router->post('login', 'LoginController@dologin'); //登录
    $router->post('index', 'IndexController@getIndex'); //首页
    //管理员
    $router->post('admin/index', 'AdminController@getIndex');
    $router->post('admin/modify', 'AdminController@modify');
    $router->post('area/listbypid', 'VillageController@areaByPid');
    //小区管理
    $router->post('village/option', 'VillageController@getOption');
    $router->post('village/index', 'VillageController@getIndex');
    $router->post('village/one', 'VillageController@getOne');
    $router->post('village/modify', 'VillageController@modify');
    $router->post('village/del', 'VillageController@del');
    $router->post('village/addresstomap', 'VillageController@addressToMap');
    //码管理
    $router->post('scene/index', 'SceneController@getIndex'); //场景
    $router->post('scene/modify', 'SceneController@modify');
    $router->post('scene/del', 'SceneController@del');
    $router->post('scene/cnt/index', 'SceneCntController@getIndex'); //场景内容
    $router->post('scene/cnt/upload/img', 'SceneCntController@uploadImg');
    $router->post('scene/cnt/upload/video', 'SceneCntController@uploadVideo');
    $router->post('scene/cnt/modify', 'SceneCntController@modify');
    $router->post('scene/cnt/del', 'SceneCntController@del');
    $router->post('qr/index', 'QrController@getIndex'); //码列表
    $router->post('qr/add', 'QrController@setAdd'); //生成码
    $router->post('qrlog/index', 'QrController@getLogIndex'); //扫码记录
    //业务模板
    $router->post('tmp/index', 'TmpController@getIndex');
    $router->post('tmp/one', 'TmpController@getOne');
    //服务管理
    $router->post('fuwu/index', 'FuwuController@getIndex');
    $router->post('fuwu/modify', 'FuwuController@modify');
    $router->post('fuwu/del', 'FuwuController@del');
    $router->post('fuwu/config/one', 'FuwuController@configOne'); //配置获取
    $router->post('fuwu/config/modify', 'FuwuController@configModify'); //配置设置
    $router->post('fuwu/sort', 'FuwuController@setSort');
    $router->post('fuwu/able', 'FuwuController@setAble');
    //服务详情
    $router->post('fwcnt/index', 'FwCntController@getIndex');
    $router->post('fwcnt/modify', 'FwCntController@modify');
    $router->post('fwcnt/del', 'FwCntController@del');
    //广告管理
    $router->post('ad/index', 'AdController@getIndex');
    $router->post('ad/modify', 'AdController@modify');
    $router->post('ad/run', 'AdController@setRun');
    $router->post('ad/del', 'AdController@setDel');
    $router->post('ad/used/list', 'AdController@usedList');
});


//前台大屏
$router->group(['prefix'=>'api/front', 'namespace'=>'Front'], function () use ($router) {
    $router->post('used', 'IndexController@usedCodeList'); //已用
    $router->post('empty', 'IndexController@emptyList'); //空码
});


//H5接口
$router->group(['prefix'=>'api/h5', 'namespace'=>'H5'], function () use ($router) {
    $router->post('user/toh5code', 'IndexController@toH5code'); //生成h5code
    $router->post('scene/index', 'IndexController@sceneIndex');
    $router->post('scene/cnt/index', 'IndexController@sceneCntIndex');
    $router->post('tmp/one', 'TmpController@getOne');
});


//H5fuwu接口
$router->group(['prefix'=>'api/h5fuwu', 'namespace'=>'H5fuwu'], function () use ($router) {
    $router->post('list', 'FuwuController@getList');
    $router->post('fuwu/one', 'FuwuController@getOne');
});


//微信小程序接口
$router->group(['prefix'=>'wxxcx', 'namespace'=>'Wxxcx'], function () use ($router) {
    //用户授权
    $router->post('wxauth', 'AuthController@wxauth');
    $router->post('user/auth', 'AuthController@auth');
    //首页列表
    $router->post('tmp/scene/sel', 'TmpController@sceneSel');
    $router->post('tmp/scene/list', 'TmpController@sceneList');
    $router->post('tmp/list', 'TmpController@getList');
    $router->post('tmp/exist', 'TmpController@exist');
    $router->post('tmp/add', 'TmpController@add');
    $router->post('tmp/one', 'TmpController@getOne');
    $router->post('tmp/upload/thumb', 'TmpController@uploadThumb');
    $router->post('tmp/modify', 'TmpController@modify');
    $router->post('tmp/attr/modify', 'TmpController@attrModify');
    $router->post('tmp/attr/del', 'TmpController@attrDel');
    //扫码
    $router->post('scene/list', 'SceneController@getList');
    $router->post('scene/cnt/list', 'SceneController@cntList');
    $router->post('scan/onebyserial', 'ScanController@getOneBySerial');
    //我的
    $router->post('my/index', 'UserController@myIndex');
    $router->post('my/scan/list', 'UserController@myScanList');
    $router->post('my/follow/list', 'UserController@myFollowList');
    $router->post('my/reply/list', 'UserController@myReplyList');
    $router->post('my/scene/list', 'UserController@mySceneList');
    $router->post('my/scene/cnt/list', 'UserController@mySceneCntList');
    //服务
    $router->post('my/fuwu/list', 'FuwuController@getList');
    $router->post('my/fuwu/jzday', 'FuwuController@jzday');
    $router->post('my/fuwu/jzimg', 'FuwuController@jzimg');
    //广告
    $router->post('my/ad/list', 'AdController@getList');
});